<?php


namespace app\unify\model;


use think\annotation\model\relation\BelongsToMany;
use think\model\concern\SoftDelete;

class Source extends Base
{

    const PLATFORM_LOCAL = 'local';

    const PLATFORM_LIST = [
        self::PLATFORM_LOCAL => '本地'
    ];

    const TYPE_IMAGE = 'image';
    const TYPE_VIDEO = 'video';
    const TYPE_FILE = 'file';
    const TYPE_LIST = [
        self::TYPE_IMAGE => '图片',
        self::TYPE_VIDEO => '视频',
        self::TYPE_FILE => '文件'
    ];

    public function getPlatformNameAttr($value, $data)
    {
        return self::PLATFORM_LIST[$data['platform']] ?? '';
    }


    public function getCreatorNameAttr($value, $data){
        return User::where([
            [User::getPrimaryKey(), '=', $data['creator']]
        ])->value('nick');
    }
}